package cn.edu.service.imp;

import cn.edu.dao.IUserDao;
import cn.edu.entity.User;
import cn.edu.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @PackageName: cn.edu.service.imp
 * @ClassName: UserServiceImp
 * @Description:
 * @author: RZS
 * @date: 2021/7/14  22:21
 */
@Service
public class UserServiceImp implements IUserService {

    @Autowired
    private IUserDao userDao;


    @Override
    public User login(User user) {
        // 判断用户是否提交登录数据
        if(user == null || user.getUsername() == null){
            throw new RuntimeException("登录失败，用户名或密码错误");
        }
        // 根据用户名查询用户数据
        User selUser = userDao.login(user.getUsername());
        return selUser;
    }
}
